<?php
// library for web viewing interfaces.
//

function put_flash_player($divname, $playerpath, $width, $height, $videopath, $splashpath, $lat, $lng, $cmtparams)
{
	// make layer
	print "<div style=\"display:block;width:$width" . "px;height:$height" . "px;\" id=\"$divname\">\n";
	//print "		<center><b>Waiting...</b></center>\n";
	print "<img src='$splashpath' width=$width height=$height>\n";
	print "</div>\n";

	// put player
	print "<script type=\"text/javascript\">\n";
	$dnlink = "\"http://get.adobe.com/flashplayer/\"";
	print "	flowplayer(\"$divname\", { 
					src: \"$playerpath\", 
					version: [8, 115], 
					onFail: function(version) {
						document.getElementById(\"$divname\").innerHTML =  
			    	       		\"Your Flash ver. \" +  
				           		\" is too old. Please update at http://get.adobe.com/flashplayer/\";
					}
				}, { 
					playlist: [
						'$videopath'
					],
					clip: { 
						autoBuffering: true,
						bufferLength: 1,
						autoPlay: false
					}, 
					plugins: { 
						controls: {
							backgroundColor: 'transparent', 
           					backgroundGradient: 'none', 
           					//buttonColor: '#114BFF', 
           					//buttonOverColor: '#7E36FF', 
      
							autoHide: 'always', 
							hideDelay: 2000,
							//stop: false, 
							fullscreen: true, 
							time: false  
						},
						// time display positioned into upper right corner 
        				time: { 
            				url: '/flowplayer/flowplayer.controls-3.1.0.swf', 
           					top:0, 
            				backgroundGradient: 'none', 
            				backgroundColor: 'transparent', 
            				buttonColor: '#254558', 
            				all: false, 
           					time: true, 
            				height:30, 
            				right:15, 
            				width:80  
        				}
					},
					/*
					onMouseOver: function() {
						this.unmute();
						//this.getControls().fadeIn();
						//this.getScreen().animate({width: 640, height: 480, left: 0}); 
						if (this.isPaused() == true) this.play();

						moveMapTo('$lat', '$lng');
						show_comment($cmtparams);
					},
					onMouseOut: function() {
						this.pause();
						//this.getControls().fadeOut(0);
						show_comment('cmt','hide');
					},*/
					onBeforeUnload: function() {
						return false;
					},
					onError: function(errCode, errorMessage) {
						//alert(errCode);
						if (errCode == 200 && this.getState() == 2) {
							this.stop();
							this.close();
							this.unload();
							//this.load();
							//this.lay();
						}
					}
			}).onStart(function() {
				// now empty..
				this.mute();
				//this.getControls().fadeOut(0);
			}).onLastSecond(function() {
				this.seek(0);
			});";
	print "</script>\n";
}

function put_input_select($label, $name, $option_array, $with_table = true)
{
	if ($with_table == true) {
    	print "<tr>\n";
    	print "<td width=150>$label:</td>\n";
    	print "<td>\n";
	}

    print "<select name=\"$name\">\n";
    for ($i = 0; $i < count($option_array); $i++) {
        if ($i == 0) {
            print "<option value=\"$option_array[$i]\" selected>$option_array[$i]</option>\n";
        }
        else {
            print "<option value=\"$option_array[$i]\">$option_array[$i]</option>\n";
        }
    }

	if ($with_table == true) {
    	print "</td>\n";
    	print "</tr>\n";
	}
}

function put_input_text($label, $name, $default_val, $with_table = true)
{
	if ($with_table == true) {
   		print "<tr>\n";
   		print "<td width=150>$label:</td>\n";
    	print "<td>\n";
	}

	print "<input type=\"text\" value=\"$default_val\" name=\"$name\" style=\"width:200px\" onclick=\"clear_field(this)\">\n";

	if ($with_table == true) {
		print "</td>\n";
    	print "</tr>\n";
	}
}

?>


